﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="activity_lookup_form.aspx.cs"
    Inherits="m_gestione_Activity_activity_lookup_form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Dettagli Attività</title>
    <link href="/timereport/include/commoncss.aspx" rel="stylesheet" type="text/css" />
</head>
<script language="JavaScript" src="/timereport/include/menu/menu_array.js" type="text/javascript"></script>
<script language="JavaScript" src="/timereport/include/menu/mmenu.js" type="text/javascript"></script>
<body>
    <table width="760" border="0">
        <tr>
            <td height="30" class="BarraTop" align="right">
                <asp:Label ID="LButente" runat="server" Text="Utente:"></asp:Label>
            </td>
        </tr>
        <tr>
            <td height="30">&nbsp;</td>
        </tr>

    <tr>
        <td>

    <form id="form1" runat="server" >

        <asp:FormView ID="FVattivita" runat="server" DataKeyNames="Activity_id" DataSourceID="DSattivita"
            EnableModelValidation="True"  DefaultMode="Insert" OnItemInserting="ItemInserting_FVattivita"
            OnItemUpdating="ItemUpdating_FVattivita" OnItemInserted="ItemInserted_FVattivita"
            OnItemUpdated="ItemUpdated_FVattivita" OnModeChanging="ItemModeChanging_FVattivita" align="center">

            <EditItemTemplate>
                <table class="TabellaForm" width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                        <th>
                            Codice&nbsp;attività
                        </th>
                        <td>
                            <asp:TextBox ID="ActivityCodeTextBox" runat="server" Text='<%# Bind("ActivityCode") %>'
                                Columns="15" MaxLength="15" CssClass="FormInputDisabled" ReadOnly="True" />                          
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Descrizione
                        </th>
                        <td>
                            <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Columns="40" CssClass="FormInput" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="NameTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Progetto
                        </th>
                        <td>
                            <asp:DropDownList ID="DDLprogetto" runat="server" Width="230px" AutoPostBack="true"
                                OnSelectedIndexChanged="DDLProgetto_SelectedIndexChanged" 
                                CssClass="FormInput">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="DDLprogetto" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Fase
                        </th>
                        <td class="style3">
                            <asp:DropDownList ID="DDLfase" runat="server" AppendDataBoundItems="True" 
                                Width="230px" CssClass="FormInput">
                                <asp:ListItem Value="">non selezionato</asp:ListItem></asp:DropDownList>
                       <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="DDLfase" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Gg Budget
                        </th>
                        <td>
                            <asp:TextBox ID="BudgetTextBox" runat="server" Text='<%# Bind("Budget") %>' Columns="10" CssClass="FormInput" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Attivo
                        </th>
                        <td>
                            <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("active") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Responsabile
                        </th>
                        <td class="style4">
                            <asp:DropDownList ID="DDLresposabile" runat="server" AppendDataBoundItems="True"
                                DataSourceID="DSpersone" DataTextField="Name" DataValueField="Persons_id" SelectedValue='<%# Bind("Responsable_id") %>'
                                Width="160px" CssClass="FormInput">
                                <asp:ListItem Value="">-- seleziona responsabile --</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Nota
                        </th>
                        <td>
                            <asp:TextBox ID="TextBox1" runat="server" Columns="40" Rows="3" Text='<%# bind("comment") %>'
                                TextMode="MultiLine" CssClass="FormInput"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <br />
                <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CssClass="FormButton"
                    CommandName="Update" Text="Aggiorna" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" CssClass="FormButton" CausesValidation="False"
                    CommandName="Cancel" Text="Annulla" />
            </EditItemTemplate>
            <InsertItemTemplate>
                <table class="TabellaForm" width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                        <th>
                            Codice&nbsp;attività
                        </th>
                        <td >
                            <asp:TextBox ID="ActivityCodeTextBox" runat="server" Text='<%# Bind("ActivityCode") %>'
                                Columns="15" MaxLength="15" CssClass="FormInput" />
                            <asp:CustomValidator ID="CustomValidator" runat="server" Display="Dynamic" ErrorMessage="Codice già esistente" OnServerValidate="ValidaAttivita_ServerValidate" ControlToValidate="ActivityCodeTextBox"></asp:CustomValidator>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="ActivityCodeTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Descrizione
                        </th>
                        <td>
                            <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Columns="40" CssClass="FormInput" />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="NameTextBox" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Progetto
                        </th>
                        <td>
                            <asp:DropDownList ID="DDLProgetto" runat="server" Width="230px" AppendDataBoundItems="True"
                                AutoPostBack="True" 
                                OnSelectedIndexChanged="DDLProgetto_SelectedIndexChanged" CssClass="FormInput">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="DDLProgetto" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Fase
                        </th>
                        <td>
                            <asp:DropDownList ID="DDLFase" runat="server" Width="230px" 
                                AppendDataBoundItems="True" CssClass="FormInput">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Campo obbligatorio"
                                ControlToValidate="DDLFase" Display="Dynamic"></asp:RequiredFieldValidator>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Gg Budget
                        </th>
                        <td>
                            <asp:TextBox ID="BudgetTextBox" runat="server" Text='<%# Bind("Budget") %>' Columns="10" CssClass="FormInput" />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Attivo
                        </th>
                        <td>
                            <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("active") %>' />
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Referente
                        </th>
                        <td>
                            <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="DSpersone" DataTextField="Name"
                                DataValueField="Persons_id" SelectedValue='<%# Bind("Responsable_id") %>' 
                                Width="160px" AppendDataBoundItems="True" CssClass="FormInput">
                                <asp:ListItem Value="">-- specifica responsabile --</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            Nota
                        </th>
                        <td>
                            <asp:TextBox ID="TextBox1" runat="server" Columns="40" Rows="3" Text='<%# bind("comment") %>'
                                TextMode="MultiLine" CssClass="FormInput"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <br />
                <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="Crea" CssClass="FormButton" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False"
                    CommandName="Cancel" Text="Annulla" CssClass="FormButton" />
            </InsertItemTemplate>
            <ItemTemplate>

            </ItemTemplate>
        </asp:FormView>

 
        <asp:SqlDataSource ID="DSattivita" runat="server" ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>"
            InsertCommand="INSERT INTO Activity(ActivityCode, Name, Phase_id, Projects_id, Budget, Active, Comment, Responsable_id) VALUES (@ActivityCode, @Name, @Phase_id, @Projects_id, @Budget, @active, @comment, @Responsable_id)"
            OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [Activity] WHERE ([Activity_id] = @Activity_id)"
            UpdateCommand="UPDATE Activity SET ActivityCode = @ActivityCode, Name = @Name, Phase_id = @Phase_id, Projects_id = @Projects_id, Budget = @Budget, Active = @active, Comment = @comment, Responsable_id = @Responsable_id WHERE (Activity_id = @original_Activity_id)">
            <InsertParameters>
                <asp:Parameter Name="ActivityCode" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Phase_id" Type="Int32" />
                <asp:Parameter Name="Projects_id" Type="Int32" />
                <asp:Parameter Name="Budget" Type="Int32" />
                <asp:Parameter Name="active" Type="Boolean" />
                <asp:Parameter Name="comment" Type="String" />
                <asp:Parameter Name="Responsable_id" />
            </InsertParameters>
            <SelectParameters>
                <asp:QueryStringParameter Name="Activity_id" QueryStringField="activity_id" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="ActivityCode" Type="String" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Phase_id" Type="Int32" />
                <asp:Parameter Name="Projects_id" Type="Int32" />
                <asp:Parameter Name="Budget" Type="Int32" />
                <asp:Parameter Name="active" Type="Boolean" />
                <asp:Parameter Name="comment" Type="String" />
                <asp:Parameter Name="Responsable_id" />
                <asp:Parameter Name="original_Activity_id" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
 
    <asp:SqlDataSource ID="DSpersone" runat="server" ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>"
        SelectCommand="SELECT Persons_id, Name, Active FROM Persons WHERE (Active = 1) ORDER BY Name">
    </asp:SqlDataSource>
    </form>

    </td>
    </tr>
    </table>

</body>
</html>
